<script type="text/javascript" charset="utf-8" src="/uedit/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="https://cdn.staticfile.org/ueditor/1.4.3/ueditor.all.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/uedit/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/ueditor/1.4.3/ueditor.parse.min.js"></script>
<link rel="stylesheet" href="/css/topicApps_detail.css">
<style>
.answer-shdow{
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(29, 32, 59, 0.85);
    width: 100%;
    height: 100%;
    z-index: 801;
    display: none;
}
.answer-content{
    width: 660px;
    height: 495px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -330px;
    margin-top: -247px;
    background: #fff;
    border-radius: 2px;
    padding: 20px;
    overflow-y: auto;
}
.answer-title-label{
	font-size: 16px;
    color: #53CAE3;
    display: block;
}
.answer-title{
    font-size: 16px;
    color: #464C7D;
    margin-top: 7px;
    margin-bottom: 10px;
}
.answer-close-img {
	width:36px;
	height:36px;
	position: absolute;
    left: 50%;
    top: 50%;
    margin-left: 372px;
    margin-top: -283px;
    cursor: pointer;
	background: url("/images/topic/bt_close.png");
}
.answer-information{
	background: rgba(70, 76, 125, 0.1);
    border-radius: 2px;
    padding: 10px;
    font-size: 14px;
    color: #464C7D;
    margin-bottom: 16px;
}
.answer-information label{
	font-weight: bold;
}
.answer-form .layui-input-code{
    width: 160px;
    display: inline-block;
    height: 30px;
    border-radius: 2px;
    border: 1px solid #464C7D;
}
.answer-information .layui-icon {
	float: right;
    cursor: pointer;
}
.answer-user-content img {
	max-width: 100%;
}
</style>
<div class="main layui-clear">
	<div class="wrap layui-clear">
		<div class="layui-left">
		    <div class="layui-bar mobile-display-none">
		    	 <div class="layui-breadcrumbs">
			    	 <a class="home" href="/"></a>
					 <i class="layui-icon">&#xe602;</i>
					 <a href="/topic/topicIndex">谈天说地</a>
					 <i class="layui-icon">&#xe602;</i>
			    	 <a href="#" title="${topic.blockparent.blockname!''}">
				    	 <#if (topic.blockparent.blockname?length>25) >
				          	${topic.blockparent.blockname[0..24]?default("")}...
				          <#else>
				          	${topic.blockparent.blockname!''}
				          </#if>
			    	</a>
		    	</div>
		    </div>
		    <div class="back-bar pc-display-none">
		    	<a href="javascript:history.go(-1);" ><i class="fa fa-angle-left"></i>返回</a>
		    </div>
		    <div class="content detail">
		      <#if topic.essence == "true">
		      	<span class="tag-tip essence"></span>
           	  <#elseif topic.hot == "true">
           	  	<span class="tag-tip hot"></span>
        	  <#else>
              </#if>
		      <h1 class="title">
		       <label class="tip-type">
	            	[<#if (topic.block.blockname?length > 5)>
	            		<label title="${topic.block.blockname!''}">${topic.block.blockname[0..4]?default("")}</label>
	            	<#else>
	            	 	${topic.block.blockname!''}
	            	</#if>]
	            </label>
		      ${topic.title!''}</h1>
		      <div class="topic-detail-about">
		         	<span class="mobile-display-none"> 作者：</span> <a class="jie-user" href="/user/otherUser/${topic.creater!''}.html"><#if topicUser??>${topicUser.username!''}<#else>${topic.username!''}</#if></a>
		            <span class="mobile-display-none"> 发布时间：</span>
		            ${topic.createtime?string('yyyy/MM/dd')}
                    <div class="edge-button">
				  	<#if  (user.usertype?? && user.usertype == "0")|| (user.id == topic.creater) >
			        	<a href="javascript:void(0)" onclick="layer.confirm('请确认是否删除主题？' , {icon: 3, title:'操作提示'},function(){location.href = '/topic/delete/${topic.id!''}.html'} ,  function(index){layer.close(index);});return false;">
			        		删除
			        	</a>
				        <#if !topic.finish>
				        	<a href="/topic/finish/${topic.id!''}.html">
				        		结贴
				        	</a>
					    <#else>
				        	<a href="/topic/unfinish/${topic.id!''}.html">
				        		取消结贴
				        	</a>
				        </#if>
				        	<a href="/topic/edit/${topic.id!''}.html">
				        		修改
				        	</a>
				     <#else>
				     	<#if topic.finish>
				     		<a href="#">
				        		已结贴
				        	</a>
				     	</#if>
				    </#if>
				  </div>
		      </div>
		      <div class="detail-body photos waterImg" style="margin-bottom: 20px;">
		      ${( topic.content?replace('<img src=', '<img src="/images/loading2.gif" lay-src=') )?no_esc}
		      </div>
		      <div class="pc-display-none mobile-show-info">
		      	浏览（${topic.views!0}） 收藏（<span class="collectNumber">${topicCollectionSize!'0'}</span>）
		      </div>
		      <!-- 分享 -->
			  <div class="share-box">
				  <a  href="#" class="weixin" id="weixin" title="分享到微信" onmouseover='getWinXixImg("${topic.id!''}","/topic/detail")'>
					 <div class="weixin-box">
						<div class="weixin-img" id="weixin${topic.id!''}"></div>
						<i class="sprite"></i>
					 </div>
				  </a>
				  <a  href="#" class="weibo" id="weibo${topic.id!''}"  title="分享到微博" onclick='getXLWBRHerf("/topic/detail","${topic.id!''}","${topic.title!''} - 盒子实验室 BOX LAB")'></a>
				  <a  href="#" class="qzone" id="qzone${topic.id!''}"  title="分享到QQ空间" onclick='getQQRHerf("/topic/detail","${topic.id!''}","${topic.title!''}","针对国内青少年STEAM创客教育建设的，提供教学案例，案例代码，国内外一手资源和创新实验信息等的开源交流社区。")'></a>
			  </div>
		      <#if topicFiles??>
		      <div class="detail-files <#if (topicFiles?size)==0>layui-hide</#if>">
		      	<h1>附件</h1>
		      	<div class="detail-li">
			      	<ul>
			      	<#list topicFiles as list>
			      		<li>
			      		  <#assign fileType=list.enclosurename?split('.')[1]>
			      			<#if "png,jpg,gif,jpeg,bmp"?contains(fileType)>
			      				<span class="file-type img"></span>
		      				<#elseif "doc,docx,dotx,xlsx,xlsm,xltx,txt"?contains(fileType)>
		      					<span class="file-type txt"></span>
		      				<#elseif "pdf"?contains(fileType)>
		      					<span class="file-type pdf"></span>
	      					<#elseif "rar,zip"?contains(fileType)>
	      						<span class="file-type rar"></span>
	      					<#else>
	      						<span class="file-type other"></span>
			      			</#if>
				      		<div class="file-content">
				      			<#if user??>
				      				<a href="javascript:" href-link="/topic/download?id=${list.enclosureid!''}" onclick="isDownload(this,'${list.creater}')">${list.enclosurename!''}</a>
				      			<#else>
				      				<a href="/login.html">${list.enclosurename!''}</a>
				      			</#if>
				      			<span>${list.filesize!''}kb 下载 ${list.download!''}次</span>
				      		</div>
			      		</li>
		      		 </#list>
			      	</ul>
		      	</div>
		      </div>
		      </#if>
		    </div>
		     <div class="topic-answer">
		     	<label class="topic-answer-title">评论</label>
		        <ul class="jieda photos" id="jieda">
		      	<#if topicCommentList??>
		      	<#list topicCommentList.content as topicComment>
		        <li class="fly-list-li">
		        <#if topicComment.username == user.username>
		          <a href="/user/profile.html" class="fly-list-avatar">
		              <img src="/${user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null" alt="">
		          </a>
		        <#else>
	        	  <a href="/user/otherUser/${topicComment.creater!''}.html" target="_blank" class="fly-list-avatar">
		              <img src="/${topicComment.user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null" alt="">
		          </a>
		        </#if>
		          <h2 class="fly-tip">
		            <a class="fly-user"> 
		                <label id="answerUser${(topicComment.id!'')}">
		                <#if topicComment.user??>${topicComment.user.username!''}<#else>${topicComment.username!''}</#if>
		                </label>
		                <#if topicComment.creater == topic.creater><b>楼主</b></#if>
		                <#if topicComment.admin?? && topicComment.admin == true><b>管理员</b></#if>
	                </a>
	                 <b class="fly-time-mobile pc-display-none"> ${topicComment.updatetime?string('MM/dd HH:mm')}</b>
		          </h2>
		          <p class="fly-time mobile-display-none">
		            <span> ${topicComment.updatetime?string('yyyy/MM/dd HH:mm:ss')}</span>
		          </p>
	             
		          <div class="detail-body jieda-body waterImg">
		          	<div class="des" id="answer${(topicComment.id!'')}">
		          	<!-- 匹配img src  懒加载图片 -->
					${( topicComment.content?replace('<img src=', '<img src="/images/loading2.gif"  lay-src=') )?no_esc}
					
		          	<#if topicComment.commentList?? &&( topicComment.commentList?size>0)>
		          	<div class="answerStorey">
		          		<#list topicComment.commentList as list>
							<div><span>${list.commentusername}</span><label>回复</label></span><span>${list.username}</span>：${(list.content!'')?no_esc}
							<#if user??>
			          	    	<a class="answer-a"  href="javascript:" onclick="answerTopic('${(list.commentid!'')}','${list.userid!''}','${list.commentusername!''}')">回复</a>
			          	    <#else>
			          	    <a class="answer-a" href="/login.html" >回复</a></a>
			          	    </#if>
			          	    </div>
						</#list>
		          	</div>
		          	</#if>
		          	</div>
		          	<div class="tool">
			          	<div class="pc-display-none">
				          	<#if (user.usertype?? && user.usertype == "0")|| (user.id == topicComment.creater)>
				              	<a href="/topic/rmcomment/${topic.id!''}/${topicComment.id!''}.html" onclick="layer.confirm('请确认是否删除评论？' , {icon: 3, title:'操作提示'},function(){location.href = '/topic/rmcomment/${topic.id!''}/${topicComment.id!''}.html'} ,  function(index){layer.close(index);});return false;"><span type="del">删除</span></a>
				              	</#if>
				              	<#if user?? && ( (user.usertype?? && user.usertype == "0") || user.id == topic.creater ) && topic.finish == false>
					              	<#if (user.usertype?? && user.usertype == "0")|| (user.id == topicComment.creater)>
					              	<span>|</span>
					              	</#if>
					              	<#if topicComment.optimal>
						              	<a href="/topic/unoptimal/${topicComment.dataid!''}/${topicComment.id!''}.html">
						              	<span class="jieda-accept" type="accept">取消采纳</span>
						              	</a><span> |</span>
					              	<#else>
						              	<a href="/topic/optimal/${topicComment.dataid!''}/${topicComment.id!''}.html">
						              	<span class="jieda-accept" type="accept">采纳</span>
						              	</a><span> |</span>
					              	</#if>
				              	 </#if>
		              	 </div>
		          		<#if user??>
		          	    <#if topicComment.user??>
		          			<a  href="javascript:" onclick="answerTopic('${(topicComment.id!'')}','${topicComment.user.id!''}','${topicComment.user.username!''}')">回复</a><span> |</span>
		          	    <#else>
		          	    	<a  href="javascript:" onclick="answerTopic('${(topicComment.id!'')}','${topicComment.id!''}','${topicComment.username!''}')">回复</a><span> |</span>
		          	    </#if>
		          	    <#else>
		          	    <a href="/login.html" >回复</a><!-- <span> |</span> --></a>
		          	    </#if>
		          		<!-- <a href="#">举报</a> -->
		          	</div>
		          </div>
		          <div class="jieda-reply mobile-display-none">
		            <div class="jieda-admin">
		            	<#if (user.usertype?? && user.usertype == "0")|| (user.id == topicComment.creater)>
		              	<a href="/topic/rmcomment/${topic.id!''}/${topicComment.id!''}.html" onclick="layer.confirm('请确认是否删除评论？' , {icon: 3, title:'操作提示'},function(){location.href = '/topic/rmcomment/${topic.id!''}/${topicComment.id!''}.html'} ,  function(index){layer.close(index);});return false;"><span type="del">删除</span></a>
		              	</#if>
		              	<#if user?? && ( (user.usertype?? && user.usertype == "0") || user.id == topic.creater ) && topic.finish == false>
			              	<#if (user.usertype?? && user.usertype == "0")|| (user.id == topicComment.creater)>
			              	<span>|</span>
			              	</#if>
			              	<#if topicComment.optimal>
				              	<a href="/topic/unoptimal/${topicComment.dataid!''}/${topicComment.id!''}.html">
				              	<span class="jieda-accept" type="accept">取消采纳</span>
				              	</a>
			              	<#else>
				              	<a href="/topic/optimal/${topicComment.dataid!''}/${topicComment.id!''}.html">
				              	<span class="jieda-accept" type="accept">采纳</span>
				              	</a>
			              	</#if>
		              	 </#if>
		            </div>
		           
		          </div>
		          <#if topicComment.optimal>
		            <i class="iconfont icon-caina" title="最佳答案"></i>
		          </#if>
		        </li>
		        </#list>
		        	<#if (topicCommentList.content?size)==0>
		        	<li class="fly-none" style="padding: 10px; height: 30px;">没有任何回答</li>
		        	</#if>
		        </#if>
		      </ul>
	        </div>
	         <div id="pages"  class="front-desk">
		     </div>
	        <div class="layui-form layui-form-pane" id="text-mobile">
	        	<div title="关闭" class="answer-close-img pc-display-none" onclick="$('#text-mobile').css('display','none')"></div>
		      	<#if topic.finish == false>
			      	<#if user??>
			        <form action="/topic/comment/${topic.id!''}.html" method="post">
			          <input type="hidden" name="comment" value="true">
			          <div class="layui-form-item layui-form-text">
			            <div class="layui-input-block">
			              <textarea id="content" name="content" lay-verify="content|checkContent|checkUeditorImg" placeholder="我要回答" style="height: 150px;"></textarea>
			            </div>
			          </div>
			          <div class="layui-form-item">
				        <div class="layui-input-block">
				          <input type="text" id="inputCode"  lay-verify="code" autocomplete="off" class="layui-input layui-input-code">
				          <div class="code-show" id="checkCode" onclick="createCode('checkCode')" > </div>
				          <span class="code-show-push"  onclick="createCode('checkCode')" >刷新</span>
				        </div>
				      </div>
			          <div class="layui-form-item">
			            <input type="hidden" name="dataid" value="${topic.id!''}">
			            <button class="button-add" id="button-one" lay-submit  lay-filter="formDemo1">回复</button>
	            		<a href="#" class="button-add layui-hide"  id="button-two">正在提交...</a>
			          </div>
			        </form>
			        <#else>
			        	<div style="text-align:center;margin-bottom: 15px;">
				        	<a href="/login.html" style="color: #53CAE3;font-weight:bold;">登录</a>
				        	后提交回答
			        	</div>
			        </#if>
		        <#else>
		      		<div style="text-align:center;margin-top:30px;">
				                              已结贴
			        </div>
		      	</#if>
		      </div>
		      
	    </div>
	    <div class="layui-right">
	    	<div class="right-edge show">
		        <div class="plate-list">
		        	<div class="card-list-user">
		        	<ul>
			        	<li class="mobile-display-none">
			        		<span class="class">
			        		<span class="class-tip see"></span></span>
		        			<span  title="${topicUser.username!''}"  class="class-title">浏览 ${topic.views!0}</span>
			        	</li>
			        	<li class="mobile-display-none">
				        	<span class="class"><span class="class-tip answer"></span></span>
		        			<span  title="${topicUser.username!''}"  class="class-title">回复 ${topic.answers!0}</span>
			        	</li>
			        	<li class="mobile-display-none">
				        	<span class="class">
				        	<#if isCollect == false>
				        		<span id="collectImg" title="收藏" class="class-tip collect" <#if user??>onclick="collectClick('${topic.id}','true')"<#else>onclick="window.location.href = '/login.html'"</#if>></span>
				        	<#else>
				        		<span id="collectImg" title="取消收藏" class="class-tip collect un" <#if user??>onclick="collectClick('${topic.id}','false')"<#else>onclick="window.location.href = '/login.html'"</#if>></span>
				        	</#if>
				        	</span>
				        	
		        			<span  title="${topicUser.username!''}"  class="class-title">收藏 <span class="collectNumber" id="collectNumber">${topicCollectionSize!''}</span></span>
			        	</li>
			        	<li class="pc-display-none">
			        		<#if user??>
			        			<span class="text-span" onmouseover="$('#text-mobile').css('display','block')">评论一下文章</span>
			        		<#else>
				        		<span class="text-span" onmouseover="window.location.href='/login.html'">评论一下文章</span>
			        		</#if>
			        	</li>
			        	<li class="pc-display-none">
				        	<span class="class">
				        	<#if isCollect == false>
				        		<span id="collectImgMobile" title="收藏" class="class-tip collect" <#if user??>onclick="collectClick('${topic.id}','true')"<#else>onclick="window.location.href = '/login.html'"</#if>></span>
				        	<#else>
				        		<span id="collectImgMobile" title="取消收藏" class="class-tip collect un" <#if user??>onclick="collectClick('${topic.id}','false')"<#else>onclick="window.location.href = '/login.html'"</#if>></span>
				        	</#if>
				        	</span>
		        			<span  title="${topicUser.username!''}"  class="class-title">收藏</span>
			        	</li>
		        	</ul>
	        		</div>
		        </div>
		    </div>
		    <div class="right-edge mobile-display-none">
		    <a class="button-add" href="/topic/add.html"><span class="button-image-pen"></span>发布新帖</a>
	    	</div>
	    	<div class="right-edge mobile-display-none">
		        <div class="recommend-section">
		        	<span class="text">关于楼主<br><span class="text-line">ABOUT</span></span>
		        </div>
		        <div class="plate-list about">
		        	<div class="card-list-user about-card-user">
			        	<#if topicUser??>
			        		<#if topicUser.username == user.username>
				        		<a href="/user/profile.html">
						        	<span class="class"><img alt="" src="/${topicUser.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null"></span>
				        			<span  title="${topicUser.username!''}"  class="class-title">${topicUser.username!''}</span>
			        			</a>
		        			<#else>
		        				<a href="/user/otherUser/${topicUser.id}.html" target="_blank">
						        	<span class="class"><img alt="" src="/${topicUser.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null"></span>
				        			<span  title="${topicUser.username!''}"  class="class-title">${topicUser.username!''}</span>
			        			</a>
		        			</#if>
			        	</#if>
	        		</div>
			        <#if userTopics??>
					<#list userTopics.content as list>
						<a href="/topic/detail/${list.id!''}.html" class="layui-clear">
							<div class="card-list">
					           <span  title="${list.title!''}"  class="class-title-line">
					           <#if (list.title?length>20) >
					          	 ${list.title[0..20]?default("")}
					          	 <#else> 
					          	 ${list.title}
					          	 </#if>
					           </span>
			        		</div>
						</a>
					</#list>
					</#if>
		        </div>
		    </div>
		    <div class="right-edge mobile-display-none">
		        <div class="recommend-section">
		        	<span class="text">热帖排行<br><span class="text-line">RANKING</span></span>
		        </div>
		        <#if hotList?? && (hotList?size>0)>
		        <div class="post-list layui-clear">
			       <ul>
						<#list hotList as relaViewsTopic>
							<li>
								<span></span>
								<a class="" href="/topic/detail/${relaViewsTopic.id!''}.html">
									${relaViewsTopic.title!''}
								</a>
							</li>
						</#list>
					</ul>
		        </div>
		        </#if>
		    </div>
		    <div class="right-edge about-us mobile-display-none">
		        <div class="recommend-section layui-hide">
		        	<span class="text">关于我们<br><span class="text-line">FOLLOW US</span></span>
		        </div>
		        <div class="plate-list" style="text-align: center;">
		        	<img alt="" src="/res/configurationFile/${configuration.imageurl!''}.html">
		        	<div class="about-content">
			        	<span class="about-title">关于我们</span><br>
			        	<span>了解更多最新资讯  领取众多福利</span>
		        	</div>
		        	
		        </div>
		    </div>
	    </div>
	    <div style="clear: both"></div>
	  </div>
  </div>
  <form id="hrefForm" class="layui-hide" method="post">
  	<input type="hidden" name="cate">
  	<input type="hidden" name="cateparent">
  	<input type="hidden" name="p">
  	<input type="hidden" name="q">
  	<input type="hidden" name="time">
  </form>
  <div id="answerShadow" class="answer-shdow">
    <div title="关闭" class="answer-close-img" onclick="$('#answerShadow').css('display','none')"></div>
  	<div class="answer-content">
  		<label class="answer-title-label">参与/回复主题</label>
  		<label class="answer-title">${topic.title!''}</label>
  		<div class="answer-information">
  			<label class="answer-user"></label>
  			<div class="answer-user-content"></div>
  		</div>
  		<div class="answer-form layui-form">
  		<form action="/topic/comment/${topic.id!''}.html" method="post">
  		     <input type="hidden" name="comment" value="false">
  		     <input type="hidden" name="dataid" value="${topic.id!''}">
  		     <input type="hidden" name="commentid" value="">
  		     <input type="hidden" name="creater" value="">
  		     <input type="hidden" name="username" value="">
	          <div class="layui-form-item layui-form-text">
	              <textarea id="contentAnswer" name="content" lay-verify="content2|checkContent" placeholder="我要回答"  style="height: 150px;"></textarea>
	          </div>
	          <div class="layui-form-item">
		          <input type="text" id="inputCodeAnswer"  lay-verify="code2" autocomplete="off" class="layui-input layui-input-code">
		          <div class="code-show" id="checkCodeAnswer" onclick="createCode('checkCodeAnswer')" > </div>
		          <span class="code-show-push"  onclick="createCode('checkCodeAnswer')" >刷新</span>
		      </div>
	          <div class="layui-form-item">
	            <input type="hidden" name="dataid" value="${topic.id!''}">
	            <button class="button-add" id="model-button-one" lay-submit  lay-filter="formDemo2">回复</button>
	            <a href="#" class="button-add layui-hide"  id="model-button-two">正在提交...</a>
	          </div>
	        </form>
  		</div>
  	</div>
  </div>
  <script>
	$(document).ready(function(){
		uParse('.detail-body', {
		    rootPath: '/uedit'
		})
		setTimeout(function(){ 
			if($("video")[0]){
				$("video")[0].play(); 
			}
		}, 1000)
	
	
	})
	
  	layui.use(['form' , 'layedit','laypage', 'layer','flow'], function(){
  		var laypage = layui.laypage;
  		var form = layui.form() ;
  		layedit = layui.layedit;
  		if(mobileTopicSign=="pc"){
  			var pageInput = true;
  		}else{
  			var pageInput = false;
  		}
  		
	  	laypage({
		    cont: 'pages'
		    ,first:'首页'
		    ,last:'末页'
		    ,pages: ${topicCommentList.totalPages}
		    ,curr:${topicCommentList.number+1}
		    ,skin: '#32c24d'
	    	,skip: pageInput
		    ,jump:function(obj, first){
		    	var curr = obj.curr;
		    	if(!first){
		    		location.href = '/topic/detail/${topic.id!""}.html?p='+curr;
		    	}
		    }
		});
	  	
	  	form.verify({ 
	  		checkUeditorImg: function(value, item){ 
	  			 if(mobileTopicSign=="pc"){
		  		  	 var data = [], status={}, imgReg = /<img.*?(?:>|\/>)/gi;
		  			 //匹配src属性
		  			 var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
	  				 var arr = ue.getContent().match(imgReg);
		  			 if(arr){
						 for (var i = 0; i < arr.length; i++){
							 if(arr[i].match(srcReg)[1].indexOf("http://")<0){
								 data.push({
							        "dataId": i,
							        "url": "http://www.myboxlab.com"+arr[i].match(srcReg)[1],
							  		"time":new Date()
							      }); 
							 }
	
						 }
					 }
		  			 if(data.length>0){
		  				var msg = msgSatatus(data);
		  			    if(msg!=""){
		  				  return msg;
		  			    }
		  			 }
	  			 }
	  		  },
	  		 content: function(value, item){
		  			 var imgReg = /<img.*?(?:>|\/>)/gi;
		  			 var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
		  			if(mobileTopicSign=="pc"){
		  				var arr = ue.getContent().match(imgReg);
		  			}else{
		  				var arr = [];
		  			}
		  			 var emimg = 0,ueditorImg=0;
		  			if(arr){
			  			 for (var i = 0; i < arr.length; i++){
							 if(arr[i].match(srcReg)[1].indexOf("http://")>=0){
								 emimg++; 
							 }else{
								 ueditorImg++;
							 }
						 }
		  			}
		  			if(mobileTopicSign=="pc"){
		  				value = ue.getContentTxt();
		  			}
			      	if((value.length+emimg*3)<=0&&ueditorImg==0) {
			  	      return '请输入正文';
			  	     }else if((value.replace(/[^\u0000-\u00ff]/g,"***").length+emimg*3) > 900){
			  	    	 return '您的内容字数超过限制！';
			  	    }else if(ueditorImg > 10){
			  	    	 return '最多上传10张图片！';
			  	    }else{}
		  	  },
			  	content2: function(value, item){ 
			  		var imgReg = /<img.*?(?:>|\/>)/gi;
		  			var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
		  			if(mobileTopicSign=="pc"){
		  				var arr = ueAnswer.getContent().match(imgReg);
		  			}else{
		  				var arr = [];
		  			}
		  			var emimg = 0,ueditorImg=0;
		  			if(arr){
			  			 for (var i = 0; i < arr.length; i++){
							 if(arr[i].match(srcReg)[1].indexOf("http://")>=0){
								 emimg++; 
							 }else{
								 ueditorImg++;
							 }
						 }
		  			}
		  			if(mobileTopicSign=="pc"){
		  				value = ueAnswer.getContentTxt();
		  			}
		        	if((value.length+emimg*3)<=0&&ueditorImg==0) {
			  	      return '请输入正文';
			  	     }else if((value.replace(/[^\u0000-\u00ff]/g,"***").length+emimg*3) > 900){
			  	    	 return '您的内容字数超过限制！';
			  	    }else if(ueditorImg > 10){
			  	    	 return '最多上传10张图片！';
			  	    }else{}
		  	  },
	  		checkContent: function(value, item){ 
				  var status = "";
					$.ajax({
						  type:"POST",
						  url:"/checkConent",
						  data: {"content": value},
						  async: false,
						  success:function(data){
							 
							   var result = JSON.parse(data.requestmsg);
							   var resultsType = result.data[0].results[0].label;
							   if(result.data[0].results[0].suggestion!="pass"){
								   switch (resultsType)
									  {
									  case "spam":
										  status='您的内容包含含垃圾信息';
									    break;
									  case "ad":
										  status='您的内容包含广告信息';
									    break;
									  case "politics":
										  status='您的内容包含渉政信息';
									    break;
									  case "terrorism":
										  status='您的内容包含暴恐信息';
									    break;
									  case "abuse":
										  status='您的内容包含辱骂信息';
									    break;
									  case "porn":
										  status='您的内容包含色情信息';
									    break;
									  case "flood":
										  status='您的内容包含灌水信息';
									    break;
									  case "contraband":
										  status='您的内容包含违禁信息';
									    break;
									  }
							   }
						  },
						  error:function(data){
							  console.log(data.requestmsg)
						  },
					  })
					  if(status!=""){
						  return status;
					  }
			  },
	  	  code: function(value, item){ 
	  	   if(value.length <= 0) {
	  	      return '请输入验证码';
	  	     }
	  	     else if(value.toUpperCase() != code.toUpperCase()) {
	  	    	createCode("checkCode");   
	  	   		return '验证码输入有误！';
	  	     }
	  	     else {} 
	  	  },
		 code2: function(value, item){ 
	  	   if(value.length <= 0) {
	  	      return '请输入验证码';
	  	     }
	  	     else if(value.toUpperCase() != codeAnswer.toUpperCase()) {
	  	    	createCode("checkCodeAnswer");   
	  	   		return '验证码输入有误！';
	  	     }
	  	     else {} 
		  },
	  	
	  	}); 
  	  var flow = layui.flow;
  	  //当你执行这样一个方法时，即对页面中的全部带有lay-src的img元素开启了懒加载（当然你也可以指定相关img）
	  	 flow.lazyimg();
  	  
  	  //提交
  	  form.on('submit(formDemo1)', function(data){
  		  $("#button-one").addClass("layui-hide");
  		  $("#button-two").removeClass("layui-hide").addClass("layui-show");
  	  }); 
  	  //提交
  	  form.on('submit(formDemo2)', function(data){
  		  $("#model-button-one").addClass("layui-hide");
  		  $("#model-button-two").removeClass("layui-hide").addClass("layui-show");
  	  }); 
	});
	UE.Editor.prototype.placeholder = function (justPlainText) {
		var _editor = this;
		_editor.addListener("focus", function () {
			var localHtml = _editor.getPlainTxt();
			if ($.trim(localHtml) === $.trim(justPlainText)) {
				_editor.setContent(" ");
			}
		});
		_editor.addListener("blur", function () {
			var localHtml = _editor.getContent();
			if (!localHtml) {
				_editor.setContent(justPlainText);
			}
		});
		_editor.ready(function () {
			_editor.fireEvent("blur");
		});
	};
	//图片懒加载之后添加水印
	function watermarkLazy(e){
		wmark.init({"path": "/res/configurationFile/${waterImg.imageurl!''}","className":"watermarkLazy" });
	}
  	if($("#content").length>0&&mobileTopicSign=="pc"){
  		var ue = UE.getEditor('content', {
  	  		//这里可以选择自己需要的工具按钮名称
  	  		toolbars: [
				['Source','|', 'undo', 'redo', 'removeformat', 'backcolor', 'formatmatch','|', 'italic', 'underline', 'Bold', 'test',
					'forecolor','|', 'justifyleft', 'justifycenter', 'justifyright','|','insertorderedlist' ,'|',
					'fontfamily', 'fontsize','|',
					 'simpleupload','emotion'
				]
			],
  	  		wordCount: false,					//开启字数统计
  	  		elementPathEnabled : false,
  	  		retainOnlyLabelPasted : true
  	  	})
  	  	
  	var ueAnswer = UE.getEditor('contentAnswer', {
  		//这里可以选择自己需要的工具按钮名称
  		toolbars: [
  	  			['italic', 'underline', 'Bold', 'test',
  	  				'forecolor','|',
  	  				'fontfamily', 'fontsize','|',
  	  				 'emotion'
  	  			]
  	  		],
  		wordCount: false,					//开启字数统计
  		elementPathEnabled : false,
  		retainOnlyLabelPasted : true
  	})
  //placeholder内容(只能是文本内容)
  	ueAnswer.placeholder("请输入正文");
	ue.placeholder("请输入正文");
	}
  	createCode("checkCode");
  	//验证码
  	function createCode(checkCodeId) {
	  	if(checkCodeId == "checkCode"){
	  		 code = "";
	  	}else{
	  		codeAnswer = "";
	  	}
	  	 var codeLength = 4; //验证码的长度
	  	 var checkCode = document.getElementById(checkCodeId);
	  	 var codeChars = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
	  	      'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
	  	      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
	  		  '1','2','3','4','5','6','7','8','9','0'); //所有候选组成验证码的字符，当然也可以用中文的
	  	 for(var i = 0; i < codeLength; i++) {
	  	  var charNum = Math.floor(Math.random() * 52);
		  	if(checkCodeId == "checkCode"){
		  		 code += codeChars[charNum];
		  	}else{
		  		codeAnswer += codeChars[charNum];
		  	}
	  	 }
	  	 if(checkCode) {
	  	    checkCode.className = "code-show";
		  	if(checkCodeId == "checkCode"){
		  		 checkCode.innerHTML = code;
		  	}else{
		  		 checkCode.innerHTML = codeAnswer;
		  	}
	  	 
	  	 }
  	}
  	
  	
  	//收藏
  	function collectClick(id,isCollect){
  		$("#collectImg,#collectImgMobile").attr("onclick","");
  		$.ajax({
			  type:"POST",
			  url:"/topic/checkCollection",
			  async:false,
			  data:{topicId:id, isCollect:isCollect},
			  success:function(data){
				  if(data.success != null){
					  if(isCollect =="true"){
						    $(".collectNumber").text(data.success);
							$("#collectImg,#collectImgMobile").addClass("un");
							$("#collectImg,#collectImgMobile").attr("onclick","collectClick('${topic.id}','false')");
							$("#collectImg,#collectImgMobile").attr("title","取消收藏");
					  }else{
						    $(".collectNumber").text(data.success);
							$("#collectImg,#collectImgMobile").removeClass("un");
							$("#collectImg,#collectImgMobile").attr("onclick","collectClick('${topic.id}','true')");
							$("#collectImg,#collectImgMobile").attr("title","收藏");
					  }
				  }else if(data.error != null){
					  $(".collectNumber").text(data.error);
				  }else{
					  window.location.href = "/login.html"
				  }
			  }
		  })
  	}
  	
  	//回复楼中楼
  	function answerTopic(id,creater,username){
  		createCode("checkCodeAnswer");
  		$("#answerShadow input[name=commentid]").val(id);
  		$("#answerShadow input[name=creater]").val(creater);
  		$("#answerShadow input[name=username]").val(username);
  		$("#answerShadow").css("display","block");
  		var text = document.getElementById("answer"+id).innerText;
  		var reg=/src=[\'\"]?([^\'\"]*)[\'\"]?/i;
  		if(text.length > 90 || (reg.test( $("#answer"+id).html() ) )){
  			$(".answer-user").html($("#answerUser"+id).text() + "<i onclick='showAnswerContent(\"show\",\""+id+"\")' class='layui-icon'>&#xe61a;</i>");
  			$(".answer-user-content").html(text.substring(0,90) + "...");
  		}else{
  			$(".answer-user").text($("#answerUser"+id).text());
  			$(".answer-user-content").text(text);
  		}
  		
  	}
  	
  	//回复内容显示
  	function showAnswerContent(action,id){
  		if(action == "show"){
  			var text = $("#answer"+id).html();
  			$(".answer-user-content").html(text);
  			$(".answer-user i").remove();
  			$(".answer-user").append("<i onclick='showAnswerContent(\"close\",\""+id+"\")' class='layui-icon'>&#xe619;</i>")
  		}else{
  			var text = $("#answer"+id).text();
 			$(".answer-user-content").html(text.substring(0,90) + "...");
  	  		$(".answer-user i").remove();
  			$(".answer-user").append("<i onclick='showAnswerContent(\"show\",\""+id+"\")' class='layui-icon'>&#xe61a;</i>")
  		}
  	}
  	  
  	
  //判断积分是否够下载
  function isDownload(down,id){
	  $.ajax({
		  type:"POST",
		  url:"/topic/isdownload",
		  async:false,
		  data:{id:id},
		  success:function(data){
			  if(data == "success"){
				  window.location.href  = $(down).attr("href-link");
			  }else{
				  layer.msg('积分不足，快去赚取积分吧', {icon: 2});
			  }
		  }
	  })
	 
  }
  
  </script>